﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevMy.Vou
{
    public partial class Form_Car1 : Form_BaseDialog
    {
        public Form_Car1()
        {
            InitializeComponent();
            this.Text = "指定批次计算";
        }
        public string Month;
        public bool IsBatchId, IsEquipmentId, IsCount;
        public string batchId, equipmentId;
        public string calType;
        public void Ini()
        {
            base.SetComponent();
            this.labelControl3.Text = Month;
        }
        /// <summary>
        /// 窗体状态
        /// </summary>
        /// <param name="WinType">-1：查看，0：修改，1：增加</param>
        public void SetWinType(int WinType)
        {
            base.WinType = WinType;
        }

        protected override void DisplayComponent(string id)
        {
            base.class_SetTextEdit.SetTextEdit(this.textEdit1, false, Color.Black);
            base.class_RadioGroup.SetRadioGroup(this.radioGroup1, null, 2);
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            int index = 0;
            IsBatchId = checkedListBoxControl1.Items[index++].CheckState == CheckState.Checked;
            IsEquipmentId = checkedListBoxControl1.Items[index++].CheckState == CheckState.Checked;
            IsCount = checkedListBoxControl1.Items[index++].CheckState == CheckState.Checked;

            if (IsBatchId)
            {
                if (this.textEdit1.Text.Length == 0)
                {
                    MessageBox.Show("请填入批次号！", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            if (IsBatchId)
                batchId = this.textEdit1.Text;
            if (IsEquipmentId)
                equipmentId = this.spinEdit1.Text;
            calType = radioGroup1.SelectedIndex == 0 ? "正应力" : "应变力";

            this.DialogResult = DialogResult.OK;
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void checkedListBoxControl1_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e)
        {
            int index = e.Index;
            switch (index)
            {
                case 0:
                    textEdit1.Enabled = checkedListBoxControl1.Items[index].CheckState == CheckState.Checked;
                    break;
                case 1:
                    spinEdit1.Enabled = checkedListBoxControl1.Items[index].CheckState == CheckState.Checked;
                    break;
                case 2:
                    break;
                default:
                    break;
            }
        }
    }
}
